/* Copyright (c) 2012-2013, Xiaomi corporation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#include <linux/mfd/pm8xxx/pm8921-bms.h>

static struct single_row_lut fcc_temp = {
	.x		= {-20, -10, 0, 5, 10, 15, 20, 25, 30, 40, 60},
	.y		= {3165, 3166, 3164, 3163, 3162, 3160, 3159, 3157, 3155, 3150, 3137},
	.cols		= 11
};

static struct single_row_lut fcc_sf = {
	.x		= {0},
	.y		= {100},
	.cols		= 1
};

static struct sf_lut rbatt_sf = { 
        .rows		= 28, 
        .cols		= 11,
        /* row_entries are temperature */
        .row_entries	= {-20, -10, 0, 5, 10, 15, 20, 25, 30, 40, 60},
        .percent	= {100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1},
        .sf		= {
{1193,566,259,192,151,126,111,100,94,88,88},
{1199,595,271,199,156,130,114,103,96,90,89},
{1188,609,286,211,164,137,119,108,100,92,90},
{1198,625,295,219,172,142,123,111,103,95,92},
{1210,641,307,230,180,149,129,115,107,97,94},
{1225,656,315,241,191,158,135,122,111,100,96},
{1241,670,319,241,201,168,145,128,117,104,98},
{1260,684,323,238,191,173,153,138,124,110,101},
{1284,704,329,238,182,150,134,125,120,112,104},
{1315,733,341,242,182,147,125,111,102,93,90},
{1351,764,360,252,187,150,128,113,103,94,91},
{1398,801,388,270,197,154,131,116,106,97,94},
{1454,839,421,296,213,165,137,120,109,101,96},
{1516,883,459,327,236,180,148,127,114,102,99},
{1589,931,497,362,261,197,160,136,120,102,92},
{1676,986,536,393,287,214,169,140,121,102,94},
{1775,1050,570,422,306,225,174,142,122,103,94},
{2048,1130,626,455,328,238,179,143,121,101,93},
{1708,1042,608,447,325,235,177,141,120,101,94},
{1752,1071,622,458,333,241,181,145,123,103,95},
{1850,1105,646,476,346,253,188,150,127,106,96},
{2041,1147,674,500,366,266,200,157,133,108,97},
{2275,1192,707,528,389,284,211,166,138,111,98},
{2604,1244,742,558,412,302,224,172,140,112,96},
{3063,1305,774,583,428,309,227,172,140,110,99},
{3801,1388,821,619,455,333,244,186,151,115,108},
{5043,1532,890,678,504,372,281,218,179,131,117},
{10471,2893,1208,876,670,509,389,304,249,146,132},

        }
};

static struct pc_temp_ocv_lut pc_temp_ocv = {
	.rows		= 29,
	.cols		= 11,
	.temp		= {-20, -10, 0, 5, 10, 15, 20, 25, 30, 40, 60},
	.percent	= {100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0},
	.ocv		= {
				{4186, 4185, 4184, 4184, 4183, 4183, 4182, 4181, 4180, 4178, 4173},
				{4114, 4118, 4122, 4123, 4124, 4124, 4124, 4123, 4123, 4122, 4119},
				{4062, 4070, 4076, 4078, 4078, 4079, 4079, 4078, 4078, 4077, 4074},
				{4003, 4018, 4030, 4033, 4034, 4036, 4036, 4037, 4036, 4036, 4033},
				{3957, 3971, 3985, 3990, 3993, 3994, 3995, 3996, 3996, 3996, 3995},
				{3920, 3933, 3949, 3956, 3959, 3961, 3962, 3962, 3963, 3962, 3960},
				{3888, 3899, 3914, 3923, 3930, 3932, 3932, 3933, 3933, 3932, 3929},
				{3860, 3868, 3879, 3887, 3897, 3903, 3904, 3905, 3905, 3905, 3901},
				{3836, 3841, 3849, 3853, 3859, 3867, 3870, 3873, 3874, 3876, 3873},
				{3815, 3820, 3824, 3826, 3828, 3831, 3833, 3835, 3837, 3839, 3838},
				{3797, 3803, 3805, 3806, 3807, 3808, 3809, 3809, 3810, 3810, 3809},
				{3779, 3788, 3791, 3792, 3792, 3792, 3793, 3794, 3794, 3794, 3793},
				{3764, 3774, 3780, 3781, 3781, 3781, 3781, 3781, 3781, 3781, 3780},
				{3749, 3761, 3769, 3772, 3773, 3773, 3773, 3772, 3772, 3770, 3769},
				{3734, 3750, 3758, 3763, 3765, 3765, 3766, 3765, 3764, 3760, 3750},
				{3718, 3738, 3745, 3751, 3755, 3755, 3755, 3754, 3752, 3746, 3731},
				{3699, 3724, 3723, 3728, 3731, 3732, 3733, 3732, 3729, 3724, 3710},
				{3672, 3704, 3700, 3698, 3696, 3694, 3692, 3690, 3687, 3683, 3673},
				{3638, 3676, 3680, 3680, 3679, 3677, 3676, 3676, 3674, 3671, 3660},
				{3627, 3668, 3676, 3676, 3676, 3675, 3674, 3673, 3673, 3669, 3658},
				{3614, 3659, 3670, 3671, 3672, 3671, 3671, 3671, 3669, 3666, 3655},
				{3598, 3645, 3660, 3663, 3665, 3665, 3665, 3665, 3663, 3659, 3646},
				{3577, 3624, 3644, 3647, 3650, 3651, 3650, 3648, 3644, 3637, 3622},
				{3549, 3595, 3614, 3617, 3618, 3616, 3613, 3610, 3605, 3598, 3581},
				{3510, 3553, 3570, 3571, 3569, 3566, 3561, 3558, 3553, 3547, 3532},
				{3454, 3495, 3508, 3507, 3503, 3500, 3495, 3493, 3490, 3487, 3473},
				{3370, 3409, 3420, 3419, 3417, 3414, 3412, 3412, 3411, 3407, 3392},
				{3231, 3283, 3295, 3295, 3293, 3291, 3289, 3286, 3285, 3285, 3266},
				{3000, 3000, 3000, 3000, 3000, 3000, 3000, 3000, 3000, 3000, 3000}
	}
};


struct pm8921_bms_battery_data lg_3000_data = {
	.fcc			= 3210,
	.fcc_temp_lut		= &fcc_temp,
	.fcc_sf_lut		= &fcc_sf,
	.pc_temp_ocv_lut	= &pc_temp_ocv,
	.rbatt_sf_lut		= &rbatt_sf,
	.default_rbatt_mohm	= 129,
};
